package com.proton.carepatchtemp.database.daomanager;

import com.proton.carepatchtemp.database.gen.MsgDao;
import com.proton.carepatchtemp.database.table.Msg;

import java.util.List;

/**
 * Created by MoonlightSW on 2017/2/21.
 */

public class MsgManager {
    private MsgDao mMsgDao;

    public MsgManager() {
        mMsgDao = GreenDaoManager.get().getmDaoSession().getMsgDao();
    }

    private static MsgDao getMsgDao() {
        return GreenDaoManager.get().getmDaoSession().getMsgDao();
    }

    public static List<Msg> getAllMsg() {
        return getMsgDao().loadAll();
    }

    public static void deleteMsgById(Long id) {
        getMsgDao().deleteByKey(id);
    }

    public static void insertOrReplaceInTx(List<Msg> msgs) {
        getMsgDao().insertOrReplaceInTx(msgs);
    }

    public static void deleteSomeById(List<Long> ids) {
        getMsgDao().deleteByKeyInTx(ids);
    }

    public static void deleteAll() {
        getMsgDao().deleteAll();
    }
}
